// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

import request from "@/utils/request.js";

/**
 * 用户提现
 *
 */
export function userWithdrawal(data) {
  return request.post("user/center/submitArraignApply", data);
}
/**
 * 获取商户付款二维码
 *
 */
export function createPaymentCodeBarCode(id) {
  return request.post(
    "sysTenant/createPaymentCodeBarCode",
    {},
    {
      newMark: true,
      id,
    }
  );
}
/**
 * 获取新接口用户信息
 *
 */
export function getUserInfoData() {
  return request.get(
    "user/info",
    {},
    {
      newMark: true,
    }
  );
}
/**
 * 获取注册商户信息
 *
 */
export function getTenantBySelf() {
  return request.get(
    "sysTenant/getTenantBySelf",
    {},
    {
      newMark: true,
    }
  );
}
/**
 * 修改用户密码
 *
 */
export function changeUserPassword(data) {
  return request.put("user/personal/password", data, {
    newMark: true,
  });
}
/**
 * 查询商户支付流水
 *
 */
export function getTenantVoucherRecordById(searchType, id) {
  return request.get(
    "sysTenant/getTenantVoucherRecordById/" + searchType,
    {},
    {
      newMark: true,
      id,
    }
  );
}
/**
 * 新首页查询商户支付全部流水
 *
 */
export function getMerchantRecords(id) {
  return request.get(
    "sysTenant/getTenantWaterBySelf",
    {},
    {
      newMark: true,
      id,
    }
  );
}
/**
 * 查询推广用户信息和销售奖励
 *
 */
export function getTenantChildrenInfoBySelf(id) {
  return request.get(
    "sysTenant/getTenantChildrenInfoBySelf",
    {},
    {
      newMark: true,
      id,
    }
  );
}
/**
 * 利息倍率
 *
 */
export function getInterestData() {
  return request.get("user/center/getHandFee");
}
/**
 * 根据id查询银行卡信息
 *
 */
export function getBankCardInfo(type) {
  return request.get(`userBankAccount/getDefaultByType/${type}`);
}
/**
 * 用户银行卡账号添加
 *
 */
export function bindBankCard(data) {
  return request.post("userBankAccount/add", data);
}
/**
 * 编辑提现绑定
 *
 */
export function editBankCard(data) {
  return request.post("userBankAccount/edit", data);
}
/**
 * 绑定关系状态
 *
 */
export function bindingRelationShip() {
  return request.get("user/isBuild");
}
/**
 * 获取用户信息
 *
 */
export function getUserInfoApi() {
  return request.get("user/info");
}
/**
 * 获取明文手机号
 *
 */
export function getPlaintextPhone() {
  return request.get("user/getPhone");
}
/**
 * 填写上级邀请码
 *
 */
export function entryInvitationCode(code) {
  return request.get("user/user/build?code=" + code);
}
/**
 * 获取用户信息以及token
 *
 */
export function logInAgain(openid) {
  return request.get("login/getUserInfo?openid=" + openid);
}

/**
 * 设置用户分享
 *
 */
export function userShare() {
  return request.post("user/share");
}
/**
 * 我的粉丝
 *
 */
export function userFansData(data) {
  return request.get("user/center/fans", data);
}
/**
 * 我的下级
 *
 */
export function userJuniorOrders(data) {
  return request.get("user/center/fansOrder", data);
}
/**
 * 我的上级
 *
 */
export function userManagerOrders(data) {
  return request.get("user/center/userGoOnline", data);
}
/**
 * h5用户登录
 * @param data object 用户账号密码
 */
export function loginH5(data) {
  return request.post("login/mobile/password", data, { noAuth: true });
}
/**
 * 新接口h5用户登录
 * @param data object 用户账号密码
 */
export function logOnH5(data) {
  return request.post(
    `login?username=${data.phone}&password=${
      data.password
    }&remember-me=${true}`,
    {},
    { noAuth: true, newMark: true }
  );
}

/**
 * h5用户手机号 验证码登录
 * @param data object
 */
export function loginMobile(data) {
  return request.post("login/mobile/captcha", data, { noAuth: true });
}

/**
 * 验证码key
 */
export function getCodeApi() {
  return request.get("verify_code", {}, { noAuth: true });
}
/**
 * 抵用券流水
 */
export function getVoucherHistory(data) {
  return request.get("points/voucherPage", data);
}
/**
 * 抵用券总数据
 */
export function getSummaryData() {
  return request.get("points/configPage");
}

/**
 * 用户注册接口
 *
 */
export function userRegister(data) {
  return request.post("user/user/register", data, { noAuth: true });
}
/**
 * 获取验证码
 *
 */
export function getVerificationCode(data) {
  return request.get("user/smsCode", data, { noAuth: true });
}
/**
 * h5用户发送验证码
 * @param data object 用户手机号
 */
export function registerVerify(phone) {
  return request.post("login/send/code", { phone: phone }, { noAuth: true });
}

/**
 * h5用户手机号注册
 * @param data object 用户手机号 验证码 密码
 */
export function register(data) {
  return request.post("register", data, { noAuth: true });
}

/**
 * 用户手机号修改密码
 * @param data object 用户手机号 验证码 密码
 */
export function registerReset(data) {
  return request.post("register/reset", data, { noAuth: true });
}

/**
 * 获取个人中心详情
 *
 */
export function userCenterInfo() {
  return request.get("user/center/info");
}

/**
 * 签到页信息
 */
export function signInfo(data) {
  return request.get("sign/page/info", data);
}

/**
 * 签到记录列表(年月)
 * @param object data
 *
 */
export function getSignMonthList(data) {
  return request.get("sign/record/list", data);
}

/**
 * 活动状态
 *
 */
export function userActivity() {
  return request.get("user/activity");
}
/**
 * 提交实名
 *
 */
export function submitRealName(data) {
  return request.post("user/center/identity", data);
}

/*
 * 余额明细（types|2=全部,1=支出,2=收入）
 * */
export function getCommissionInfo(data) {
  return request.get("retail/store/brokerage/record", data);
}

/*
 * 用户结算记录
 * */
export function getClosingRecordApi(data) {
  return request.get("retail/store/user/closing/record", data);
}

/*
 * 提现总金额
 * */
export function getCountApi() {
  return request.get("extract/totalMoney");
}

/*
 * 积分记录
 * */
export function getIntegralList(q) {
  return request.get("user/center/integral/list", q);
}

/**
 * 获取分销海报图片
 *
 */
export function spreadBanner() {
  return request.get("retail/store/user/poster/banner");
}

/**
 *
 * 获取推广用户一级和二级
 * @param object data
 */
export function spreadPeople(data) {
  return request.get("retail/store/spread/people/list", data);
}

/**
 *
 * 推广佣金/提现总和
 * @param int type
 */
export function spreadCount(type) {
  return request.get("spread/count/" + type);
}

/*
 * 推广数据 当前佣金 提现总金额
 * */
export function myPromotion() {
  return request.get("user/center/my/promotion");
}

/**
 *
 * 推广订单
 * @param object data
 */
export function spreadOrder(data) {
  return request.get("retail/store/spread/order/list", data);
}

/*
 * 获取推广人排行
 * */
export function getRankList(type) {
  return request.get("retail/store/spread/people/rank", type);
}

/*
 * 获取佣金排名
 * */
export function getBrokerageRank(type) {
  return request.get("retail/store/brokerage/rank", type);
}

/**
 * 用户结算申请
 * @param object data
 */
export function extractCash(data) {
  return request.post("retail/store/user/closing/apply", data);
}

/**
 * 会员等级列表
 *
 */
export function userLevelGrade() {
  return request.get("user/level/grade");
}

/**
 * 获取某个等级任务
 * @param int id 任务id
 */
export function userLevelTask(id) {
  return request.get("user/level/task/" + id);
}

/**
 * 检查用户是否可以成为会员
 *
 */
export function userLevelDetection() {
  return request.get("user/level/detection");
}

/**
 *
 * 地址列表
 */
export function getAddressList() {
  return request.get("address/list");
}

/**
 * 设置默认地址
 * @param int id
 */
export function setAddressDefault(id) {
  return request.post(`address/set/default/${id}`);
}

/**
 * 修改 地址
 * @param object data
 */
export function editAddress(data) {
  return request.post("address/edit", data);
}

/**
 * 添加 地址
 * @param object data
 */
export function addAddress(data) {
  return request.post("address/add", data);
}

/**
 * 删除地址
 * @param int id
 *
 */
export function delAddress(id) {
  return request.post(`address/delete/${id}`);
}

/**
 * 地址详情
 * @param int id
 */
export function getAddressDetail(id) {
  return request.get(`address/detail/${id}`);
}

/**
 * 获取微信地址信息
 * @param object data
 */
export function getWxAddressInfo(data) {
  return request.post(`address/wechat/info`, data);
}

/**
 * 修改用户信息
 * @param object
 */
export function userEdit(data) {
  return request.post("user/user/edit", data);
}

/*
 * 退出登录
 * */
export function getLogout() {
  return request.get("login/logout");
}
/*
 * 生成二维码
 * */
export function getShareCode() {
  return request.get("qr/qr");
}
/*
 * 获取海报
 * */
export function getPoster(data) {
  return request.get(
    `qr/posterImg?nickname=${data.nickname}&avatar=${data.avatar}&text=${data.text}`
  );
}
// /*
//  * 下载海报
//  * */
// export function downloadPoster() {
//   return request.get("qr/posterImgDown", {
//     responseType: 'blob', // 指定响应类型为 Blob
//   });
// }
/**
 * 注销账户
 * @param object data
 *
 */
export function userOut(data) {
  return request.post(`user/logoff`, data);
}

/**
 * 小程序充值
 *
 */
export function rechargeRoutine(data) {
  return request.post("recharge/routine", data);
}
/*
 * 公众号充值
 * */
export function rechargeWechat(data) {
  return request.post("recharge/wechat", data);
}

/*
 * app微信充值
 * */
export function appWechat(data) {
  return request.post("recharge/wechat/app", data);
}

/*
 * 佣金转入
 * */
export function transferIn(data) {
  return request.post("retail/store/brokerage/to/yue", data, 1);
}

/*
 * 生成用户充值订单
 * */
export function rechargeCreateApi(data) {
  return request.post("recharge/user/create", data);
}

/*
 * 支付宝充值
 * */
export function alipayFull(data) {
  return request.post("recharge/alipay", data, {});
}

/**
 * 获取默认地址
 *
 */
export function getAddressDefault() {
  return request.get("address/get/default");
}

/**
 * 充值金额选择
 */
export function getRechargeApi() {
  return request.get("recharge/get/user/package");
}

/**
 * 登录记录
 */
export function setVisit(data) {
  return request.post("user/set_visit", { ...data }, { noAuth: true });
}

/**
 * 客服列表
 */
export function serviceList() {
  return request.get("user/service/lst");
}
/**
 * 客服详情
 */
export function getChatRecord(to_uid, data) {
  return request.get("user/service/record/" + to_uid, data);
}

/**
 * 绑定推广关系
 * @param {number} spreadPid
 */
export function spreadApi(spreadPid) {
  return request.post(`retail/store/binding/user/${spreadPid}`);
}

/**
 * 会员等级经验值；
 *
 */
export function getlevelInfo() {
  return request.get("user/center/user/level/grade");
}

/**
 * 经验值明细；
 *
 */
export function getlevelExpList(data) {
  return request.get("user/expList", data);
}

/**
 * 我的账户金额明细；
 *
 */
export function getMyAccountApi() {
  return request.get("user/center/my/account");
}

/**
 * 账单记录；
 *
 */
export function getBillList(data) {
  return request.get("user/center/balance/record", data);
}
/**
 * 提现记录
 *
 */
export function getWithdrawalList(data) {
  return request.get("user/center/getUserArraignApplyList", data);
}

/*
 * 积分中心详情
 * */
export function postIntegralUser() {
  return request.get("user/center/my/integral");
}

/*
 * 推广人统计页 推广人数（一级+二级）、一级人数、二级人数
 * */
export function spreadPeoCount() {
  return request.get("retail/store/spread/people/team/num");
}

/*
 * 用户结算配置
 * */
export function closingConfigApi() {
  return request.get("retail/store/user/closing/config");
}

/*
 * 足迹记录
 * */
export function browseRecordApi() {
  return request.get("user/center/browse/record");
}

/*
 * 我的经验
 * */
export function myExpApi() {
  return request.get("user/center/my/exp");
}

/*
 * 我的经验记录列表
 * */
export function myExpRecordApi(data) {
  return request.get("user/center/my/exp/record/list", data);
}

/**
 * 版权图片
 */
export function copyrightImageApi() {
  return request.get(`index/copyright/company/image`, {}, { noAuth: true });
}

/**
 * 版权图片
 */
export function userLevelRuleApi() {
  return request.get(`agreement/user/level/rule`);
}
